﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Wicresoft.Framework.Organization;
using Wicresoft.Common;
using System.Collections.Generic;
using Monthly.Framework.BusinessLogic;

public partial class Page_MonthlyDetail : BaseAuthenticationPage
{
    public Guid MonthlyID
    {
        get
        {
            if (Request.QueryString["ID"] != null)
                return new Guid(Request.QueryString["ID"]);
            return Guid.Empty;
        }
    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "科室周报详细清单";
        this.UseTabber = true;
        BindData();
    }

    protected void lbtnDelete_Click(object sender, EventArgs e)
    {
        MonthlyDB.Entity.Monthly monthly = new MonthlyDB.Entity.Monthly(MonthlyID);
        monthly.Delete();
        BLMonthly.DeleteAttachments(MonthlyID);
        ClientScript.RegisterStartupScript(this.GetType(), "Delete", "<script>parent.location.href = parent.location.href</script>");
    }

    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        BindData();
        ClientScript.RegisterStartupScript(this.GetType(), "Finish", "<script>parent.document.getElementById('ctl00$ListToolBarPlaceHolder$btnRefresh').click();</script>");
    }
    private void BindData()
    {
        MonthlyDB.Entity.Monthly monthly = new MonthlyDB.Entity.Monthly(MonthlyID);
        monthly.Load();

        lbtnDelete.Visible = true;
        tdEdit.Visible = true;

        ltlFileName.Text = monthly.FileName;
        ltlKeywords.Text = monthly.Keywords;
        ltlPublishTime.Text = monthly.PublishTime.ToString("yyyy-MM-dd");
        ltlSymbol.Text = monthly.Symbol;
       
        ltlContent.Text = monthly.Content;

        DataTable dtAttach = BLMonthly.getAttachmentsByMonthlyID(MonthlyID);
        rptAttachmentList.DataSource = dtAttach;
        rptAttachmentList.DataBind();
    }
}

